package com.example.demo.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.entity.Test;
import com.example.demo.service.ITestService;

@RestController
@RequestMapping("/test")
public class TestController {
	

	@Autowired
	private ITestService testService;
	
	@GetMapping("/insert")
	public int insertTest(Test test) {
		return testService.insertTest(test);
	}
	
	@GetMapping("/getjson")
	public Map<String, Object> getjson() {
		Map<String, Object> data = new HashMap<>();
		data.put("int", 1);
		data.put("string", "阿斯蒂芬");
		data.put("bool", true);
		return data;
	}
	
	@PostMapping("/getAll")
	public List<Test> getAll(@RequestBody Test test) {
		return testService.getAll(test);
	}
	
	@PostMapping("/update")
	public int update(@RequestBody Test test) {
		return testService.update(test);
	}
	
	@PostMapping("/getPage")
	public Page<Test> getPage(@RequestBody Page<Test> page) {
		return testService.getPage(page);
	}
}
